package com.neusoft.proxy.three;

import org.springframework.cglib.proxy.Enhancer;

public class TestCgLib {
    public static void main(String[] args) {
        //1. 创建cglib代理增强对象
        Enhancer enhancer = new Enhancer();
        //2. 设置被代理类的超类
        enhancer.setSuperclass(SuperMarket.class);
        //3. 设置代理方法的增强方法的拦截器
        enhancer.setCallback(new MethodHandler());
        //4. 生成代理对象
        SuperMarket superMarket = (SuperMarket) enhancer.create();
        //5. 调用方法
        superMarket.deliverGoods();

    }
}
